/*###################################################################*
#
# MPGL Engine - CrossPlatform OpenGL Engine
# Copyright (C) 2014  Mitchell Pell
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
####################################################################*/

#ifndef GL_APP_H
#define GL_APP_H

/*! Include Drawable */
#include "../Base/Drawable.h"

/*! Include Logical */
#include "../Base/Logical.h"

/*! Include ErrorHandler */
#include "../GLDriver/GLDriverComponents/Console/GLConsole.h"

/*! Include GLAppComponents */
#include "GLAppComponents/GLAppComponents.h"

/*! Include GLAppScene */
#include "../GLScene/GLAppScene.h"

using namespace mpgl_engine::scene;

namespace mpgl_engine{ 
	/*! @brief MPGL engine, application layer. */
	namespace application{

		/*!----------------------------------------------------------------
		*	@class		GLApp
		*	@brief		Template for a GL Application to be run by the
		*				GLDriver class.
		*
		*	@author		Mitchell Pell
		*	@date		9/27/2013
		*	@version	1.0
		*
		-----------------------------------------------------------------*/
		class GLApp : public Drawable, public Logical
		{
		public:
			/*! Default Constructor */
			GLApp(GlConsole* console = NULL);

			/*! Default Destructor */
			virtual ~GLApp();	
			/*! Initializes GLApp and GLAppComponents */
			virtual void Initialize();
			/*! Loads any content needed globally by the Application */
			virtual void LoadContent();	
			/*! Continuous call that updates the application */
			virtual void Update();	
			/*! Continuous call that draws the application */
			virtual void Draw();		
			/*! Updates the applications logic */
			virtual void UpdateLogic();
			/*! Unloads the Application */
			virtual void Uninitialize();
			/*! Unloads any global content */
			virtual void UnloadContent();		
			/*! Loads a scene */
			void LoadScene(GLAppScene* scene);
			/*! Unloads the current scene  */
			void UnloadCurrentScene();
		
			/*!   */
			/*bool IsNetworkingThreadEnabled()
				{return m_networkThreadEnabled; }*/   

			/*!   */
			NetworkManager* GetNetworkManager(){return m_ac->m_network; }
		
			/*!   */
			GLFWwindow* GetWindow(){ if (m_ac==NULL) return NULL; 
				return m_ac->m_glWindow->GetWindow();}

			void SetConsole(GlConsole* console)
				{m_ac->SetGlConsole(console); }

		protected:
			/*! Collection of Components  */
			GLAppComponents*		m_ac;
			/*! Current Application Scene */
			GLAppScene*				m_scene;
			/*!  */
			bool m_networkThreadEnabled;

		};
}}

#endif